package com.bungarus.device.config;

import com.bungarus.device.model.DeviceGrpcApplication;
import com.bungarus.device.model.DeviceGrpcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.EventListener;

import java.io.IOException;

@Configuration
public class DeviceConfig {
    @Autowired
    private DeviceGrpcService grpcService;

    @EventListener({ApplicationStartedEvent.class})
    public void startGrpcServerAfterWebServiceStarted() throws IOException, InterruptedException {
        new DeviceGrpcApplication(grpcService).init();
    }
}
